package com.study.services;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.PageRequest;
import org.springframework.data.domain.Sort.Direction;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Transactional;

import com.study.dao.IBookDao;
import com.study.dao.IUserDao;
import com.study.exception.ServiceException;
import com.study.model.pojo.TBook;
import com.study.model.pojo.User;


/**
 * ͼ��ҵ�������
 * @author kangshan
 *
 */
@Service
@Transactional(rollbackFor=ServiceException.class)
public class BookServices {
		
		@Autowired
		IUserDao iUserDao;
		@Autowired 
		IBookDao id;//图书  从表 主维控方
		
		
		/**
		 * �����û�
		 */
		public void addUser(User user){
			try {
				iUserDao.save(user);
			} catch (Exception e) {
				e.printStackTrace();
				throw new ServiceException("����û�ʧ��");
			}
		}
		/**
		 * 分页查询所有图书信息
		 */
		public List<TBook> getPage(int page,int size){
			PageRequest pageable=new PageRequest(page-1, size,Direction.DESC,"bid");
			return id.queryBy(pageable);
		}


}
